//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace OpenLS.UI
{
    ///<summary>
    /// Represents a group inside a ribbon tab
    ///</summary>
    public class Group : HeaderedItemsControl
    {

        ///<summary>
        /// Get or set the group state
        ///</summary>
        public GroupState GroupState
        {
            get { return (GroupState)GetValue(GroupStateProperty); }
            set { SetValue(GroupStateProperty, value); }
        }

        // Using a DependencyProperty as the backing store for GroupState.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty GroupStateProperty =
            RibbonElement.GroupStateProperty.AddOwner(typeof (Group));


        // Using a DependencyProperty as the backing store for IsCollapseEnabled.  This enables animation, styling, binding, etc...


        public StatePriority MediumStatePriority
        {
            get { return (StatePriority)GetValue(MediumStatePriorityProperty); }
            set { SetValue(MediumStatePriorityProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MediumStatePriority.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MediumStatePriorityProperty =
            DependencyProperty.Register("MediumStatePriority", typeof(StatePriority), typeof(Group), new UIPropertyMetadata(StatePriority.Never));



        public StatePriority SmallStatePriority
        {
            get { return (StatePriority)GetValue(SmallStatePriorityProperty); }
            set { SetValue(SmallStatePriorityProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SmallStatePriority.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SmallStatePriorityProperty =
            DependencyProperty.Register("SmallStatePriority", typeof(StatePriority), typeof(Group), new UIPropertyMetadata(StatePriority.Never));



        public StatePriority CollapsedStatePriority
        {
            get { return (StatePriority)GetValue(CollapsedStatePriorityProperty); }
            set { SetValue(CollapsedStatePriorityProperty, value); }
        }

        // Using a DependencyProperty as the backing store for CollapsedStatePriority.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CollapsedStatePriorityProperty =
            DependencyProperty.Register("CollapsedStatePriority", typeof(StatePriority), typeof(Group), new UIPropertyMetadata(StatePriority.MaxValue));	

        

        ///<summary>
        /// Get or set the command for the group button
        ///</summary>
        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValue(CommandProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Command.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CommandProperty =
            DependencyProperty.Register("Command", typeof(ICommand), typeof(Group), new UIPropertyMetadata(null));



        ///<summary>
        /// Get or set the command parameter of the group button. This is meaningful only if the Command is set.
        ///</summary>
        public object CommandParameter
        {
            get { return GetValue(CommandParameterProperty); }
            set { SetValue(CommandParameterProperty, value); }
        }

        // Using a DependencyProperty as the backing store for CommandParameter.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CommandParameterProperty =
            DependencyProperty.Register("CommandParameter", typeof(object), typeof(Group), new UIPropertyMetadata(null));



        internal List<GroupVariant> GetGroupVariants()
        {
            List<GroupVariant> result = new List<GroupVariant>();
            StatePriority d = MediumStatePriority;
            if (d.IsEnabled)
                result.Add(new GroupVariant(d.Value, GroupState.Medium));
            
            d = SmallStatePriority;
            if (d.IsEnabled)
                result.Add(new GroupVariant(d.Value, GroupState.Small));

            d = CollapsedStatePriority;
            if (d.IsEnabled)
                result.Add(new GroupVariant(d.Value, GroupState.Collapsed));
            return result;
        }
    }
}
